package com.atguigu.javase.thread;


class Singleton {
    private static Singleton instance = null;

    private Singleton() {

    }

    public static Singleton getInstance() {
        if (instance == null) {
            instance = new Singleton();
        }
        return instance;
    }
}

class MyRunner implements Runnable {

    @Override
    public void run() {
        Singleton instance = Singleton.getInstance();
        System.out.println(instance);
    }
}

public class SingletonTest {

    public static void main(String[] args) {
        Runnable runner = new MyRunner();

        new Thread(runner).start();
        new Thread(runner).start();
        new Thread(runner).start();
    }
}
